<?php
class twig2Controller extends \Hyang\Controller
{
   public function indexAction()
   {
       $str = '
            <title>Twig 4 Symfony-非文件加载测试</title>
            Wrox {{ test }}!
            <br>{{ about }}
            <br><a href="/wjtai/twig2/about.html" target="_blank">详见</a>
            <br><a href="twig2/about.html" target="_blank">详见</a>
       ';
       $tpl = $this->view->loadTemplate($str);
       echo $tpl->display(array(
           'test' => 'example'
           ,'about' => '来自Symfony 2.0框架的模板引擎'
        ));       
   }
   public function aboutAction()
   {
       $file = _VIEW.'Twig2/about.html';
       $str = '
            <title>{{ title }}</title>
            <div>
                <ul>
                    <li><a href="{{ site }}" target="_blank">官网</a></li>
                    <li><a href="http://twig.sensiolabs.org/doc/coding_standards.html" target="_blank">编码规则</a></li>          
                    <li><a href="http://twig.sensiolabs.org/api/master/index.html" target="_blank">API</a></li>                                    
                </ul>
                <br>{{ 7+9 }}
                <br>{{ fuck|default("I never say FUCK to u? U Damn, understand?") }}
            </div>
            {{ include(\''.$file.'\',sandboxed = true)}}
       ';
       $tpl = $this->view->loadTemplate($str);
       echo $tpl->display(array(           
           'site' => 'http://twig.sensiolabs.org/'
           ,'title'=>'关于Twig'
        ));     
   }
   public function _init()
   {
       $this->selfViewParam = array(
           'name' => 'Twig'
           ,'option' => [14,414]
       );
   }
}